load("@rules_proto//proto:defs.bzl", "proto_library")

# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

##############################################################################
# Common
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")

_PROTO_SUBPACKAGE_DEPS = [
    "//google/devtools/containeranalysis/v1beta1/attestation:attestation_proto",
    "//google/devtools/containeranalysis/v1beta1/build:build_proto",
    "//google/devtools/containeranalysis/v1beta1/common:common_proto",
    "//google/devtools/containeranalysis/v1beta1/cvss:cvss_proto",
    "//google/devtools/containeranalysis/v1beta1/deployment:deployment_proto",
    "//google/devtools/containeranalysis/v1beta1/discovery:discovery_proto",
    "//google/devtools/containeranalysis/v1beta1/grafeas:grafeas_proto",
    "//google/devtools/containeranalysis/v1beta1/image:image_proto",
    "//google/devtools/containeranalysis/v1beta1/package:package_proto",
    "//google/devtools/containeranalysis/v1beta1/provenance:provenance_proto",
    "//google/devtools/containeranalysis/v1beta1/source:source_proto",
    "//google/devtools/containeranalysis/v1beta1/vulnerability:vulnerability_proto",
]

proto_library(
    name = "containeranalysis_proto",
    srcs = [
        "containeranalysis.proto",
    ],
    deps = [
        "//google/api:annotations_proto",
        "//google/api:client_proto",
        "//google/api:field_behavior_proto",
        "//google/api:resource_proto",
        "//google/iam/v1:iam_policy_proto",
        "//google/iam/v1:policy_proto",
        "@com_google_protobuf//:empty_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

proto_library_with_info(
    name = "containeranalysis_proto_with_info",
    deps = [
        ":containeranalysis_proto",
        "//google/cloud:common_resources_proto",
    ] + _PROTO_SUBPACKAGE_DEPS,
)

##############################################################################
# Java
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "java_gapic_assembly_gradle_pkg",
    "java_gapic_library",
    "java_gapic_test",
    "java_grpc_library",
    "java_proto_library",
)

_JAVA_PROTO_SUBPACKAGE_DEPS = [
    "//google/devtools/containeranalysis/v1beta1/attestation:attestation_java_proto",
    "//google/devtools/containeranalysis/v1beta1/build:build_java_proto",
    "//google/devtools/containeranalysis/v1beta1/common:common_java_proto",
    "//google/devtools/containeranalysis/v1beta1/deployment:deployment_java_proto",
    "//google/devtools/containeranalysis/v1beta1/discovery:discovery_java_proto",
    "//google/devtools/containeranalysis/v1beta1/grafeas:grafeas_java_proto",
    "//google/devtools/containeranalysis/v1beta1/image:image_java_proto",
    "//google/devtools/containeranalysis/v1beta1/package:package_java_proto",
    "//google/devtools/containeranalysis/v1beta1/provenance:provenance_java_proto",
    "//google/devtools/containeranalysis/v1beta1/source:source_java_proto",
    "//google/devtools/containeranalysis/v1beta1/vulnerability:vulnerability_java_proto",
]

_JAVA_GRPC_SUBPACKAGE_DEPS = [
    "//google/devtools/containeranalysis/v1beta1/attestation:attestation_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/build:build_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/common:common_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/deployment:deployment_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/discovery:discovery_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/grafeas:grafeas_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/image:image_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/package:package_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/provenance:provenance_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/source:source_java_grpc",
    "//google/devtools/containeranalysis/v1beta1/vulnerability:vulnerability_java_grpc",
]

java_proto_library(
    name = "containeranalysis_java_proto",
    deps = [":containeranalysis_proto"],
)

java_grpc_library(
    name = "containeranalysis_java_grpc",
    srcs = [":containeranalysis_proto"],
    deps = [":containeranalysis_java_proto"],
)

java_gapic_library(
    name = "containeranalysis_java_gapic",
    srcs = [":containeranalysis_proto_with_info"],
    gapic_yaml = "containeranalysis_gapic.yaml",
    grpc_service_config = "containeranalysis_grpc_service_config.json",
    rest_numeric_enums = True,
    service_yaml = "containeranalysis_v1beta1.yaml",
    test_deps = [
        ":containeranalysis_java_grpc",
    ] + _JAVA_GRPC_SUBPACKAGE_DEPS,
    transport = "grpc+rest",
    deps = [
        ":containeranalysis_java_proto",
        "//google/iam/v1:iam_java_proto",
    ] + _JAVA_PROTO_SUBPACKAGE_DEPS,
)

java_gapic_test(
    name = "containeranalysis_java_gapic_test_suite",
    test_classes = [
        "com.google.cloud.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1ClientHttpJsonTest",
        "com.google.cloud.devtools.containeranalysis.v1beta1.ContainerAnalysisV1Beta1ClientTest",
        "com.google.cloud.devtools.containeranalysis.v1beta1.GrafeasV1Beta1ClientHttpJsonTest",
        "com.google.cloud.devtools.containeranalysis.v1beta1.GrafeasV1Beta1ClientTest",
    ],
    runtime_deps = ["containeranalysis_java_gapic_test"],
)

# Open Source Packages
java_gapic_assembly_gradle_pkg(
    name = "google-cloud-devtools-containeranalysis-v1beta1-java",
    transport = "grpc+rest",
    deps = [
        ":containeranalysis_java_gapic",
        ":containeranalysis_java_grpc",
        ":containeranalysis_java_proto",
        ":containeranalysis_proto",
    ] + _JAVA_GRPC_SUBPACKAGE_DEPS + _JAVA_PROTO_SUBPACKAGE_DEPS + _PROTO_SUBPACKAGE_DEPS,
)

##############################################################################
# Go
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "go_gapic_assembly_pkg",
    "go_gapic_library",
    "go_proto_library",
)

go_proto_library(
    name = "containeranalysis_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "cloud.google.com/go/containeranalysis/apiv1beta1/containeranalysispb",
    protos = [":containeranalysis_proto"],
    deps = [
        "//google/api:annotations_go_proto",
        "//google/iam/v1:iam_go_proto",
    ],
)

go_gapic_library(
    name = "containeranalysis_go_gapic",
    srcs = [":containeranalysis_proto_with_info"],
    grpc_service_config = "containeranalysis_grpc_service_config.json",
    importpath = "cloud.google.com/go/containeranalysis/apiv1beta1;containeranalysis",
    release_level = "beta",
    rest_numeric_enums = True,
    service_yaml = "containeranalysis_v1beta1.yaml",
    transport = "grpc+rest",
    deps = [
        ":containeranalysis_go_proto",
        "//google/devtools/containeranalysis/v1beta1/attestation:attestation_go_proto",
        "//google/devtools/containeranalysis/v1beta1/build:build_go_proto",
        "//google/devtools/containeranalysis/v1beta1/common:common_go_proto",
        "//google/devtools/containeranalysis/v1beta1/deployment:deployment_go_proto",
        "//google/devtools/containeranalysis/v1beta1/discovery:discovery_go_proto",
        "//google/devtools/containeranalysis/v1beta1/grafeas:grafeas_go_proto",
        "//google/devtools/containeranalysis/v1beta1/image:image_go_proto",
        "//google/devtools/containeranalysis/v1beta1/package:package_go_proto",
        "//google/devtools/containeranalysis/v1beta1/provenance:provenance_go_proto",
        "//google/devtools/containeranalysis/v1beta1/source:source_go_proto",
        "//google/devtools/containeranalysis/v1beta1/vulnerability:vulnerability_go_proto",
        "//google/iam/v1:iam_go_proto",
    ],
)

# Open Source Packages
go_gapic_assembly_pkg(
    name = "gapi-cloud-devtools-containeranalysis-v1beta1-go",
    deps = [
        ":containeranalysis_go_gapic",
        ":containeranalysis_go_gapic_srcjar-snippets.srcjar",
        ":containeranalysis_go_gapic_srcjar-test.srcjar",
        ":containeranalysis_go_proto",
        "//google/devtools/containeranalysis/v1beta1/attestation:attestation_go_proto",
        "//google/devtools/containeranalysis/v1beta1/build:build_go_proto",
        "//google/devtools/containeranalysis/v1beta1/common:common_go_proto",
        "//google/devtools/containeranalysis/v1beta1/deployment:deployment_go_proto",
        "//google/devtools/containeranalysis/v1beta1/discovery:discovery_go_proto",
        "//google/devtools/containeranalysis/v1beta1/grafeas:grafeas_go_proto",
        "//google/devtools/containeranalysis/v1beta1/image:image_go_proto",
        "//google/devtools/containeranalysis/v1beta1/package:package_go_proto",
        "//google/devtools/containeranalysis/v1beta1/provenance:provenance_go_proto",
        "//google/devtools/containeranalysis/v1beta1/source:source_go_proto",
        "//google/devtools/containeranalysis/v1beta1/vulnerability:vulnerability_go_proto",
    ],
)

##############################################################################
# Node.js
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "nodejs_gapic_assembly_pkg",
    "nodejs_gapic_library",
)

nodejs_gapic_library(
    name = "containeranalysis_nodejs_gapic",
    package_name = "@google-cloud/containeranalysis",
    src = ":containeranalysis_proto_with_info",
    extra_protoc_parameters = ["metadata"],
    grpc_service_config = "containeranalysis_grpc_service_config.json",
    main_service = "containeranalysis",
    package = "google.devtools.containeranalysis.v1beta1",
    rest_numeric_enums = True,
    service_yaml = "containeranalysis_v1beta1.yaml",
    transport = "grpc+rest",
    deps = [],
)

nodejs_gapic_assembly_pkg(
    name = "devtools-containeranalysis-v1beta1-nodejs",
    deps = [
        ":containeranalysis_nodejs_gapic",
        ":containeranalysis_proto",
    ] + _PROTO_SUBPACKAGE_DEPS,
)
